#include<iostream>
using namespace std;
int main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		int n;
		cin >> n;
		int* a = new int[n];
		for (int j = 0; j < n; j++) {
			cin >> a[j];
		}
		int m;
		cin >> m;
		int* mid = a + n / 2;
		cout << *(--mid);
		mid++;
		cout << ' ' << *(++mid) << endl;
		cout << *(a + m - 1) << endl;
	}
}